package cn.xuewenbao.edu.mapper;

import cn.xuewenbao.edu.entity.ColumnType;
import cn.xuewenbao.edu.entity.vo.MyLikeOrFavoriteContentVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 专栏名称表 Mapper 接口
 * </p>
 *
 * @author mafayu
 * @since 2021-04-19
 */
@Mapper
public interface ColumnTypeMapper extends BaseMapper<ColumnType> {

    @Select("SELECT title, cover, view_count, content " +
            "FROM ${tableName} " +
            "WHERE id = #{contentId} ")
    MyLikeOrFavoriteContentVo selectTitleCoverViewCount(String contentId, String tableName);

    //课程专用
    @Select("SELECT title, cover, buy_count, price " +
            "FROM ${tableName} " +
            "WHERE id = #{contentId} ")
    MyLikeOrFavoriteContentVo selectTitleCoverBuyCount(String contentId, String tableName);

    //期刊专用
    @Select("SELECT js.sub_title, js.view_count, js.number, js.content, j.cover " +
            "FROM ${tableName} js LEFT JOIN journal j ON js.parent_id = j.id " +
            "WHERE js.id = #{contentId} ")
    MyLikeOrFavoriteContentVo selectSubTitleNumberViewCount(String contentId, String tableName);

    @Select("SELECT cover, title, description, view_count\n" +
            "FROM ${tableName} " +
            "WHERE id = #{contentId} ")
    MyLikeOrFavoriteContentVo selectTitleCoverDesciptionViewCount(String contentId, String tableName);
}
